package com.mitaotao._1_语法._4_循环.单循环._01_输出最大值;

import java.util.Scanner;

public class _01_2_依次输入10个数输出最大值 {
    public static void main(String[] args) {
        //依次输入10个数，输出最大值
        Scanner scanner = new Scanner(System.in);
        int num1,num2;
        int max = 0;
        System.out.println("请输入第1个数字：");
        num1 = scanner.nextInt();
        System.out.println("请输入第2个数字：");
        num2 = scanner.nextInt();
        if (num1>num2){
            max = num1;
        }
        for (int n=3;n<=10;n++){
            System.out.println("请输入第"+n+"个数字：");
            num1 = scanner.nextInt();
            if (num1>max){
                max = num1;
            }
        }
        System.out.println("最大值为"+max);
        scanner.close();
    }
}
